<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item
        label="活动报名时间"
        prop="enrollTime"
        label-width="130px"
      >
        <el-date-picker
          clearable
          v-model="queryParams.enrollTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择活动报名时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="用户电话" prop="phoneNumber">
        <el-input
          v-model="queryParams.phoneNumber"
          placeholder="请输入用户电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="活动赛事标题" prop="eventTitle" label-width="100px">
        <el-input
          v-model="queryParams.eventTitle"
          placeholder="请输入活动赛事标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="eventList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="eventTitle" />
      <el-table-column label="电话" align="center" prop="phoneNumber" />
      <el-table-column label="活动标题" align="center" prop="eventTitle" />
      <el-table-column label="封面图" align="center" prop="eventImg">
        <template v-slot:default="scope">
          <el-image
            :src="scope.row.eventImg"
            :zoom-rate="2.4"
            :max-scale="8"
            :min-scale="0.9"
            :preview-src-list="[scope.row.eventImg]"
          />
        </template>
      </el-table-column>
      <el-table-column label="实际支付" align="center" prop="price" />
      <el-table-column label="支付方式" align="center" prop="payType" >
        <template slot-scope="scope">
          <span> {{onPayType(scope.row.payType)  }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="报名时间"
        align="center"
        prop="enrollTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.enrollTime, "{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-pie-chart"
            @click="handleDeatil(scope.row)"
            v-hasPermi="['business:event:edit']"
            >详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 详情抽屉 -->
    <el-drawer
      title="订单详情"
      :visible.sync="drawer"
      :before-close="handleClose"
      size="50%"
    >
      <div class="allBox">
        <el-descriptions title="用户信息">
          <el-descriptions-item label="姓名">{{ form.fullName }}</el-descriptions-item>
          <el-descriptions-item label="年龄">{{ form.age }}</el-descriptions-item>
          <el-descriptions-item label="电话">{{ form.eventPhone }}</el-descriptions-item>
          <el-descriptions-item label="身份证">{{ form.idcard }}</el-descriptions-item>
          <el-descriptions-item label="报名时间">{{ form.enrollTime }}</el-descriptions-item>
        </el-descriptions>
        <el-divider></el-divider>
        <el-descriptions title="活动信息">
          <el-descriptions-item label="活动标题">{{ form.eventTitle }}</el-descriptions-item>
          <el-descriptions-item label="活动封面">
            <img class="img" :src="form.eventImg" alt="">
          </el-descriptions-item>
        </el-descriptions>
        <el-divider></el-divider>
        <el-descriptions title="支付信息">
          <el-descriptions-item label="活动价格">{{ form.price }}</el-descriptions-item>
          <el-descriptions-item label="支付价格">{{ form.price }}</el-descriptions-item>
          <!-- <el-descriptions-item label="积分抵扣金额">{{ form.enrollTime }}</el-descriptions-item> -->
          <el-descriptions-item label="订单号">{{ form.recordNo }}</el-descriptions-item>
        </el-descriptions>
      </div>
    </el-drawer>
  </div>
</template>
  
  <script>
import { getEvent, listEvent,getOrderList } from "@/api/business/event";

export default {
  name: "Event",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 活动管理表格数据
      eventList: [],
      // 是否显示弹出层
      drawer: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        eventType: 1,
        eventTitle: null,
        eventImg: null,
        phoneNumber: null,
        enrollStartTime: null,
        enrollEndTime: null,
        startTime: null,
        endTime: null,
        eventDescribe: null,
        state: null,
        enrollTime:null,
        status:1
      },
      // 表单参数
      form: {
        fullName:''
      },

      imageUrl: "",
      editorContent: "",
      signUpRecordParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询活动管理列表 */
    getList() {
      this.loading = true;
      getOrderList(this.queryParams).then((response) => {
        this.eventList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },

    /** 详情按钮操作 */
    handleDeatil(row) {
      this.form =row;
      this.drawer = true;

    },    
    handleClose() {
      this.drawer = false;
    },
    onPayType(type){
      switch (type) {
        case 'wx':
          return "微信支付";
        case 'alipay':
          return "支付宝支付";

        default:
          return "";
      }
    }
  },
};
</script>
  
  <style scoped lang="scss">
.modal-wrap {
  ::v-deep .el-dialog__body {
    height: 600px;
    overflow-y: scroll;
  }
}

.avatar-uploader {
  ::v-deep .el-upload {
    width: 100px;
    height: 100px;
    border: 1px dotted #eee;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .avatar-uploader-icon {
    font-size: 24px;
  }
}

.banner-img {
  width: 100px;
  height: 100px;
  // margin-left: 20px;
}
.allBox{
    padding-left: 25px;
}
.img{
  width: 150px;
  height: 150px;
}
</style>
  